package com.wuzhishan.news.mapper;

import com.wuzhishan.news.pojo.BlogUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface userMapper {
    /**
     * 插入用户
     * @param user
     * @return
     */
    int insertUser(BlogUser user);

    /**
     * 根据用户名和密码查询是否存在对应的用户
     * @param username
     * @return
     */
    BlogUser findUserByUsername(@Param("username") String username);

    /**
     * 根据邮箱查询是否存在对应的用户
     * @param email
     * @return
     */
    BlogUser findUserByEmail(String email);

    void updatePassword(@Param("id") long id, @Param("password") String password);

    void updateProfile(@Param("nickname") String nickname,@Param("sign") String sign,@Param("id") long id);

    BlogUser getOneById(long id);

    void updateAvatar(@Param("id") long id, @Param("avatar") String avatar);

    List<BlogUser> findHotUsers(long maxResults);
}
